<!--
   Based on the original:
   Copyright (C) 2012 by Jeremy P. White <jwhite@codeweavers.com>

   This file is part of spice-html5.

   spice-html5 is free software: you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   spice-html5 is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.

   --------------------------------------------------
    Spice Javascript client template.
    Refer to main.js for more detailed information
   --------------------------------------------------

-->

<!doctype html>
<html>
<head>
	<!-- Stylesheets -->
	<link rel="stylesheet" type="text/css" href="css/app.css" title="plain">
	<link rel="stylesheet" type="text/css" href="css/spice-custom.css" />
</head>

<body>
  <main>
    <div style="background: #f7f7f7; padding: 1.5em 1.5em 0.8em;">
      <div style="max-width: 1250px; margin: 0 auto;">
        <div id="noVNC_status_bar" class="noVNC_status_bar" style="display: flex; align-items: center;">
          <img src="images/opennebula-5.0.png" style="height:40px;">
          <h5 id="message-div" class="spice-message"></h5>
        </div>
        <div class="SPICE_info"></div>
      </div>
    </div>

    <div id="spice-area">
      <div id="spice-screen" class="spice-screen"></div>
    </div>

    <div id="debug-div">
    <!-- If DUMPXXX is turned on, dumped images will go here -->
    </div>
	</main>

	<script src="dist/console/spice.js?v=<%= OpenNebula::VERSION %>"></script>
  <% view = $views_config.view(session[:user], session[:user_gname], session[:default_view]) %>
	<script type="text/javascript">
      var csrftoken = '<%= session[:csrftoken] %>';
      var view = JSON.parse('<%= view.to_json %>')
      var available_views = JSON.parse('["<%=
          $views_config.available_views(session[:user], session[:user_gname]).join('","')
        %>"]')
      var all_labels = JSON.parse('["<%=
          $views_config.get_all_labels(session[:user_gname]).join('","')
        %>"]')
      var all_views = JSON.parse('["<%=
          $views_config.get_all_views.join('","')
        %>"]')
      if ('<%= $conf[:addons] %>'){
        var addons = JSON.parse('<%= $conf[:addons].to_json %>');
      }
      var config = {
        'user_config' : {
            'lang' : '<%= session[:lang] %>',
            'vnc_wss' : '<%= session[:vnc_wss] %>',
            'table_order' : '<%= session[:table_order] %>',
            'default_view' : '<%= session[:default_view] %>',
            'page_length' : '<%= session[:page_length] %>'
        },
        'system_config' : {
            'marketplace_url' : '<%= $conf[:marketplace_url] %>',
            'vnc_request_password' : <%= $conf[:vnc_request_password] || false %>,
            'vnc_proxy_port' : '<%= $vnc.proxy_port %>',
            'vnc_client_port' : '<%= $conf[:vnc_client_port] %>',
            'max_upload_file_size' : <%= $conf[:max_upload_file_size] ? $conf[:max_upload_file_size] : "undefined" %>
        },
        'view' : view,
        'available_views' : available_views,
        'all_labels' : all_labels,
        'all_views' : all_views,
        'user_id' : '<%= session[:user_id] %>',
        'user_gid' : '<%= session[:user_gid] %>',
        'display_name' : '<%= session[:display_name] %>',
        'zone_name' : '<%= session[:zone_name] %>',
        'zone_id' : '<%= session[:zone_id] %>',
        'federation_mode' : '<%= session[:federation_mode] %>',
        'vm_logos' : <%= logos_conf.to_json %>,
        'oned_conf' : <%= oned_conf.to_json %>,
        'support' : <%= support.to_json %>,
        'upgrade' : <%= upgrade.to_json %>,
        'mode' : '<%= session[:mode] %>'
      };
  </script>
</body>
</html>
